package com.jn.erp.wechat.common.api.service.impl;

import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jn.erp.web.api.student.entity.StudentUser;
import com.jn.erp.web.api.student.service.StudentUserService;
import com.jn.erp.wechat.common.api.entity.WxAccess;
import com.jn.erp.wechat.common.api.entity.dto.WxMaLoginDto;
import com.jn.erp.wechat.common.api.service.WxAccessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * <pre>
 *
 * </pre>
 *
 * @author sunjiyong
 * @since 2024/10/31 16:51
 */

@Service
public class WxAccessServicePlus{


    @Autowired
    private StudentUserService studentUserService;

    @Autowired
    private WxAccessService wxAccessService;


    //根据openId获取学生家长信息
    public StudentUser getByWxStudentAccessId(Long wxAccessId) {
        QueryWrapper<StudentUser> qw=new QueryWrapper<>();
        qw.eq("wx_access_id",wxAccessId);
        qw.eq("state", 0);
        return studentUserService.getOne(qw);
    }


    public WxAccess logMpRecord(WxMaJscode2SessionResult session , WxMaLoginDto loginDto, String from){
        WxAccess access = wxAccessService.logMpRecord(session, loginDto, from);
        return access;
    }
}
